home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  7.4 KB  |  339 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dialog;
  6. import java.awt.Frame;
  7. import java.awt.Graphics;
  8. import java.awt.GraphicsConfiguration;
  9. import java.awt.LayoutManager;
  10. import java.awt.Window;
  11. import java.awt.Dialog.ModalityType;
  12. import java.awt.event.WindowEvent;
  13. import java.awt.event.WindowListener;
  14. import javax.accessibility.Accessible;
  15. import javax.accessibility.AccessibleContext;
  16. import sun.awt.SunToolkit;
  17.  
  18. public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer, TransferHandler.HasGetTransferHandler {
  19.    private static final Object defaultLookAndFeelDecoratedKey = new StringBuffer("JDialog.defaultLookAndFeelDecorated");
  20.    private int defaultCloseOperation;
  21.    protected JRootPane rootPane;
  22.    protected boolean rootPaneCheckingEnabled;
  23.    private TransferHandler transferHandler;
  24.    protected AccessibleContext accessibleContext;
  25.  
  26.    public JDialog() {
  27.       this((Frame)null, false);
  28.    }
  29.  
  30.    public JDialog(Frame var1) {
  31.       this(var1, false);
  32.    }
  33.  
  34.    public JDialog(Frame var1, boolean var2) {
  35.       this((Frame)var1, (String)null, var2);
  36.    }
  37.  
  38.    public JDialog(Frame var1, String var2) {
  39.       this(var1, var2, false);
  40.    }
  41.  
  42.    public JDialog(Frame var1, String var2, boolean var3) {
  43.       super(var1 == null ? SwingUtilities.getSharedOwnerFrame() : var1, var2, var3);
  44.       this.defaultCloseOperation = 1;
  45.       this.rootPaneCheckingEnabled = false;
  46.       this.accessibleContext = null;
  47.       if (var1 == null) {
  48.          WindowListener var4 = SwingUtilities.getSharedOwnerFrameShutdownListener();
  49.          this.addWindowListener(var4);
  50.       }
  51.  
  52.       this.dialogInit();
  53.    }
  54.  
  55.    public JDialog(Frame var1, String var2, boolean var3, GraphicsConfiguration var4) {
  56.       super(var1 == null ? SwingUtilities.getSharedOwnerFrame() : var1, var2, var3, var4);
  57.       this.defaultCloseOperation = 1;
  58.       this.rootPaneCheckingEnabled = false;
  59.       this.accessibleContext = null;
  60.       if (var1 == null) {
  61.          WindowListener var5 = SwingUtilities.getSharedOwnerFrameShutdownListener();
  62.          this.addWindowListener(var5);
  63.       }
  64.  
  65.       this.dialogInit();
  66.    }
  67.  
  68.    public JDialog(Dialog var1) {
  69.       this(var1, false);
  70.    }
  71.  
  72.    public JDialog(Dialog var1, boolean var2) {
  73.       this((Dialog)var1, (String)null, var2);
  74.    }
  75.  
  76.    public JDialog(Dialog var1, String var2) {
  77.       this(var1, var2, false);
  78.    }
  79.  
  80.    public JDialog(Dialog var1, String var2, boolean var3) {
  81.       super(var1, var2, var3);
  82.       this.defaultCloseOperation = 1;
  83.       this.rootPaneCheckingEnabled = false;
  84.       this.accessibleContext = null;
  85.       this.dialogInit();
  86.    }
  87.  
  88.    public JDialog(Dialog var1, String var2, boolean var3, GraphicsConfiguration var4) {
  89.       super(var1, var2, var3, var4);
  90.       this.defaultCloseOperation = 1;
  91.       this.rootPaneCheckingEnabled = false;
  92.       this.accessibleContext = null;
  93.       this.dialogInit();
  94.    }
  95.  
  96.    public JDialog(Window var1) {
  97.       this(var1, ModalityType.MODELESS);
  98.    }
  99.  
  100.    public JDialog(Window var1, Dialog.ModalityType var2) {
  101.       this(var1, (String)null, var2);
  102.    }
  103.  
  104.    public JDialog(Window var1, String var2) {
  105.       this(var1, var2, ModalityType.MODELESS);
  106.    }
  107.  
  108.    public JDialog(Window var1, String var2, Dialog.ModalityType var3) {
  109.       super(var1, var2, var3);
  110.       this.defaultCloseOperation = 1;
  111.       this.rootPaneCheckingEnabled = false;
  112.       this.accessibleContext = null;
  113.       this.dialogInit();
  114.    }
  115.  
  116.    public JDialog(Window var1, String var2, Dialog.ModalityType var3, GraphicsConfiguration var4) {
  117.       super(var1, var2, var3, var4);
  118.       this.defaultCloseOperation = 1;
  119.       this.rootPaneCheckingEnabled = false;
  120.       this.accessibleContext = null;
  121.       this.dialogInit();
  122.    }
  123.  
  124.    protected void dialogInit() {
  125.       this.enableEvents(72L);
  126.       this.setLocale(JComponent.getDefaultLocale());
  127.       this.setRootPane(this.createRootPane());
  128.       this.setRootPaneCheckingEnabled(true);
  129.       if (isDefaultLookAndFeelDecorated()) {
  130.          boolean var1 = UIManager.getLookAndFeel().getSupportsWindowDecorations();
  131.          if (var1) {
  132.             this.setUndecorated(true);
  133.             this.getRootPane().setWindowDecorationStyle(2);
  134.          }
  135.       }
  136.  
  137.       SunToolkit.checkAndSetPolicy(this, true);
  138.    }
  139.  
  140.    protected JRootPane createRootPane() {
  141.       JRootPane var1 = new JRootPane();
  142.       var1.setOpaque(true);
  143.       return var1;
  144.    }
  145.  
  146.    protected void processWindowEvent(WindowEvent var1) {
  147.       super.processWindowEvent(var1);
  148.       if (var1.getID() == 201) {
  149.          switch (this.defaultCloseOperation) {
  150.             case 0:
  151.             default:
  152.                break;
  153.             case 1:
  154.                this.setVisible(false);
  155.                break;
  156.             case 2:
  157.                this.dispose();
  158.          }
  159.       }
  160.  
  161.    }
  162.  
  163.    public void setDefaultCloseOperation(int var1) {
  164.       if (var1 != 0 && var1 != 1 && var1 != 2) {
  165.          throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
  166.       } else {
  167.          int var2 = this.defaultCloseOperation;
  168.          this.defaultCloseOperation = var1;
  169.          this.firePropertyChange("defaultCloseOperation", var2, var1);
  170.       }
  171.    }
  172.  
  173.    public int getDefaultCloseOperation() {
  174.       return this.defaultCloseOperation;
  175.    }
  176.  
  177.    public void setTransferHandler(TransferHandler var1) {
  178.       TransferHandler var2 = this.transferHandler;
  179.       this.transferHandler = var1;
  180.       SwingUtilities.installSwingDropTargetAsNecessary(this, this.transferHandler);
  181.       this.firePropertyChange("transferHandler", var2, var1);
  182.    }
  183.  
  184.    public TransferHandler getTransferHandler() {
  185.       return this.transferHandler;
  186.    }
  187.  
  188.    public void update(Graphics var1) {
  189.       this.paint(var1);
  190.    }
  191.  
  192.    public void setJMenuBar(JMenuBar var1) {
  193.       this.getRootPane().setMenuBar(var1);
  194.    }
  195.  
  196.    public JMenuBar getJMenuBar() {
  197.       return this.getRootPane().getMenuBar();
  198.    }
  199.  
  200.    protected boolean isRootPaneCheckingEnabled() {
  201.       return this.rootPaneCheckingEnabled;
  202.    }
  203.  
  204.    protected void setRootPaneCheckingEnabled(boolean var1) {
  205.       this.rootPaneCheckingEnabled = var1;
  206.    }
  207.  
  208.    protected void addImpl(Component var1, Object var2, int var3) {
  209.       if (this.isRootPaneCheckingEnabled()) {
  210.          this.getContentPane().add(var1, var2, var3);
  211.       } else {
  212.          super.addImpl(var1, var2, var3);
  213.       }
  214.  
  215.    }
  216.  
  217.    public void remove(Component var1) {
  218.       if (var1 == this.rootPane) {
  219.          super.remove(var1);
  220.       } else {
  221.          this.getContentPane().remove(var1);
  222.       }
  223.  
  224.    }
  225.  
  226.    public void setLayout(LayoutManager var1) {
  227.       if (this.isRootPaneCheckingEnabled()) {
  228.          this.getContentPane().setLayout(var1);
  229.       } else {
  230.          super.setLayout(var1);
  231.       }
  232.  
  233.    }
  234.  
  235.    public JRootPane getRootPane() {
  236.       return this.rootPane;
  237.    }
  238.  
  239.    protected void setRootPane(JRootPane var1) {
  240.       if (this.rootPane != null) {
  241.          this.remove(this.rootPane);
  242.       }
  243.  
  244.       this.rootPane = var1;
  245.       if (this.rootPane != null) {
  246.          boolean var2 = this.isRootPaneCheckingEnabled();
  247.  
  248.          try {
  249.             this.setRootPaneCheckingEnabled(false);
  250.             this.add(this.rootPane, "Center");
  251.          } finally {
  252.             this.setRootPaneCheckingEnabled(var2);
  253.          }
  254.       }
  255.  
  256.    }
  257.  
  258.    public Container getContentPane() {
  259.       return this.getRootPane().getContentPane();
  260.    }
  261.  
  262.    public void setContentPane(Container var1) {
  263.       this.getRootPane().setContentPane(var1);
  264.    }
  265.  
  266.    public JLayeredPane getLayeredPane() {
  267.       return this.getRootPane().getLayeredPane();
  268.    }
  269.  
  270.    public void setLayeredPane(JLayeredPane var1) {
  271.       this.getRootPane().setLayeredPane(var1);
  272.    }
  273.  
  274.    public Component getGlassPane() {
  275.       return this.getRootPane().getGlassPane();
  276.    }
  277.  
  278.    public void setGlassPane(Component var1) {
  279.       this.getRootPane().setGlassPane(var1);
  280.    }
  281.  
  282.    public Graphics getGraphics() {
  283.       JComponent.getGraphicsInvoked(this);
  284.       return super.getGraphics();
  285.    }
  286.  
  287.    public void repaint(long var1, int var3, int var4, int var5, int var6) {
  288.       if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
  289.          RepaintManager.currentManager(this).addDirtyRegion(this, var3, var4, var5, var6);
  290.       } else {
  291.          super.repaint(var1, var3, var4, var5, var6);
  292.       }
  293.  
  294.    }
  295.  
  296.    public static void setDefaultLookAndFeelDecorated(boolean var0) {
  297.       if (var0) {
  298.          SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
  299.       } else {
  300.          SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
  301.       }
  302.  
  303.    }
  304.  
  305.    public static boolean isDefaultLookAndFeelDecorated() {
  306.       Boolean var0 = (Boolean)SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey);
  307.       if (var0 == null) {
  308.          var0 = Boolean.FALSE;
  309.       }
  310.  
  311.       return var0;
  312.    }
  313.  
  314.    protected String paramString() {
  315.       String var1;
  316.       if (this.defaultCloseOperation == 1) {
  317.          var1 = "HIDE_ON_CLOSE";
  318.       } else if (this.defaultCloseOperation == 2) {
  319.          var1 = "DISPOSE_ON_CLOSE";
  320.       } else if (this.defaultCloseOperation == 0) {
  321.          var1 = "DO_NOTHING_ON_CLOSE";
  322.       } else {
  323.          var1 = "";
  324.       }
  325.  
  326.       String var2 = this.rootPane != null ? this.rootPane.toString() : "";
  327.       String var3 = this.rootPaneCheckingEnabled ? "true" : "false";
  328.       return super.paramString() + ",defaultCloseOperation=" + var1 + ",rootPane=" + var2 + ",rootPaneCheckingEnabled=" + var3;
  329.    }
  330.  
  331.    public AccessibleContext getAccessibleContext() {
  332.       if (this.accessibleContext == null) {
  333.          this.accessibleContext = new AccessibleJDialog(this);
  334.       }
  335.  
  336.       return this.accessibleContext;
  337.    }
  338. }
  339.